//轮播图
window.onload = function(){
	var box = document.getElementById('box');
	var img = box.getElementsByTagName('img');
	var ul = document.getElementsByClassName('ul')[0];
	var li = ul.getElementsByTagName('li');
	var num = 0;
	var btn_L = document.getElementById('btn_L');
	var btn_R = document.getElementById('btn_R');
	
	function run(){
		num++;
		if(num == 2){
			num = 0;
		}
		for(i = 0;i < img.length;i++){
			img[i].style.display = "none";
			li[i].style.color = "black";
			li[i].style.background = "white";
		}

		img[num].style.display = "block";
		li[num].style.color ="#D20979";
		li[num].style.background = "#D20979";
	}
	timer = setInterval(run,4000);

	box.onmouseover = function(){
		clearInterval(timer);
	}
	box.onmouseout = function(){
		timer = setInterval(run,1000);
	}

	for(i = 0;i < li.length;i++){
		li[i].xuhao = i;

	li[i].onmouseover= function(){
			num = this.xuhao;

		for(j = 0;j < img.length;j++){
			img[j].style.display = "none";
			li[j].style.color = "black";
			li[j].style.background = "white";
		}

		img[num].style.display = "block";
		li[num].style.color ="#D20979";
		li[num].style.background = "#D20979";
	}
}

	btn_L.onclick= function(){					
		if(num == 0){
			num = 2;
		}
		num--;
		
		for(k = 0;k < img.length;k++){
			img[k].style.display = "none";
			li[k].style.color = "black";
			li[k].style.background = "white";
		}

		img[num].style.display = "block";
		li[num].style.color ="#D20979";
		li[num].style.background = "#D20979";
	}

	btn_R.onclick= function(){
		num++;		
		if(num == 2){
			num = 0;
		}
		
		for(z = 0;z < img.length;z++){
			img[z].style.display = "none";
			li[z].style.color = "black";
			li[z].style.background = "white";
		}

		img[num].style.display = "block";
		li[num].style.color ="#D20979";
		li[num].style.background = "#D20979";
	}
}


// Foot无缝滚动条
	var num2 = 0;
	function run1(){
		num2++;
		if(num2 == 4){
			num2 = 1;
			$(".Foot7").css({top:0});			
		}
		var t = -30*num2;
		$(".Foot7").animate({top:t + "px"},300);
	}
	timer2 = setInterval(run1,2000);

//内容页图片切换
$(function(){
	
	//product	浏览图切换
    $(".pic_n").mouseover(function(){
    	var num = $(this).index();
        $(".pic_x").eq(num).fadeIn(500).siblings().stop().fadeOut(200);
    });
    
	//product	详细清单切换
	var gm = $('.goods_mess_t');
	gm.each(function(index){
		$(this).click(function(){
			gm.attr('class', 'me');
			$(this).attr('class', 'mess_select');
		});
	});
	
    $(".goods_mess_t").click(function(){
    	var num = $(this).index();    		$(".goods_mess_t").eq(num).css({background:"white"}).siblings().css({background:""});
        $(".cont").eq(num).fadeIn(500).siblings().stop().fadeOut(200);
    });
 
    //member 
	var mem = $('.member_max');
	mem.each(function(index){
		$(this).click(function(){
			mem.attr('class', 'm');
			$(this).attr('class', 'h');
		});
	});
	
	//个人中心tab切换
    $(".member_left_move").click(function(){
		var num = $(this).index();   
	    $(".member_info").eq(num).fadeIn(500).siblings().stop().fadeOut(200);
    });
    
    //添加地址弹窗
	$(".add_function").click(function(){ 
		$(".m5 .add_address").slideDown(800);
		$(".cover").css({display:"block"})
    });
    //修改地址弹窗
    $(".edit").click(function(){ 
		$(".m5 .edit_address").slideDown(800);
		$(".cover").css({display:"block"})
    });
    
    $(".closebtn").click(function(){ 
		$(".m5 .add_address").slideUp(500);
		$(".cover").css({display:"none"})
    });
   	$(".closebtn").click(function(){ 
		$(".m5 .edit_address").slideUp(500);
		$(".cover").css({display:"none"})
    });
    
    
    //默认地址
//	var address_li = $('.address_li');
//	address_li.each(function(index){
//		$(this).click(function(){
//			$(this).attr('class', 'de_add').siblings().attr('class', 'address_li');
//		});
//	});
	
	
	//products	商品详情购买数量
	var gsn = $('.goods_s_num');
	gsn.each(function(index){
		$(this).click(function(){
			gsn.attr('class', 'goods_s_num');
			$(this).attr('class', 'gsn_hover');
		});
	});
	
	
	//填写购物信息附言
	$i=1;
	var aLi = $('.order_mes');
	aLi.each(function(index){
		$(this).click(function(){
			if($i==1){
				aLi.attr('class', 'order_mes');
				$(this).attr('class', 'order_add_mes');
				$(".order_mes_input").stop().fadeIn(100);				
				$i=0;
			}else if($i==0){
				aLi.attr('class', 'order_mes');
				$(this).attr('class', 'order_mes');
				$(".order_mes_input").fadeOut(100);				
				$i=1;
			}	
		});
	});
})

